home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2002 #11
/
Amiga Plus CD - 2002 - No. 11.iso
/
Tools
/
ShareMailGiftware
/
AmigaTalk
/
general
/
Semaphore.st
< prev
next >
Wrap
Text File
|
2002-10-27
|
800b
|
31 lines
"-----------------------------------------------------------"
" Semaphore Class is NOT the same as Amiga Exec Semaphores. "
"-----------------------------------------------------------"
Class Semaphore :List ! excessSignals !
[
new
excessSignals <- 0
|
new: aNumber
excessSignals <- aNumber
|
signal
<primitive 148>. "start atomic action"
(self isEmpty)
ifTrue: [excessSignals <- excessSignals + 1]
ifFalse: [self removeFirst unblock].
<primitive 149> "end atomic action"
|
wait
<primitive 148>. "start atomic actions"
(excessSignals = 0)
ifTrue: [self addLast: selfProcess. selfProcess block]
ifFalse: [excessSignals <- excessSignals - 1].
<primitive 149> "end atomic actions"
]